Ext.namespace('Ext.ux');
Ext.ux.CrudPage = Ext.extend(Ext.Panel,{
	layout:'border',
	treeConfig:null,
	gridConfig:null,
	style:'margin:2',
	initComponent : function(){   
        Ext.ux.CrudPage.superclass.initComponent.call(this);
	},
    onRender : function(ct, position){
    	Ext.ux.CrudPage.superclass.onRender.call(this, ct, position);
    	if(this.topConfig){
    		var cfg=Ext.applyIf(this.topConfig,{split:true,region:'north',collapseMode : 'mini'});
    		this.top=MiaUtil.getFormPanel(cfg);
    		this.add(this.top);
    	}
    	if(this.treeConfig){
    		this.tree=MiaUtil.getTreePanel(Ext.applyIf(this.treeConfig,{region:'west',width:120}));
    		this.add(this.tree);
    	}
    	if(this.gridConfig){
			this.grid=MiaUtil.getGridPanel(Ext.applyIf(this.gridConfig,{hideBorders:true,region:'center'}));
    		this.add(this.grid);
    	}
    }
});
Ext.reg('crud', Ext.ux.CrudPage);

Ext.ux.FormPage = Ext.extend(Ext.Window,{
	modal : true,
	closeAction : 'hide',
	buttonAlign : 'center',
	border : false,
	actions:null,
	fields:[],
	form:null,
	actions:null,
	ct:null,//按钮名称参数
	target:null,
	id:'frm',
	width:350,
	initComponent : function(){
		var ct=Ext.applyIf(ct||{},Constants.btn);
        Ext.ux.FormPage.superclass.initComponent.call(this);
        if(!this.form){
			this.form =MiaUtil.getFormPanel(this.initialConfig);
		}
		this.add(this.form);
		for(var act in this.actions){
			this.addButton({text:ct[act],handler:this.actions[act],id:"btn-"+this.id+"-"+act});
		}	
	}
});

Ext.ux.QueryPage = Ext.extend(Ext.Window,{
	title:'查询',
	width:350,
	height:250,
	closeAction : 'hide',
	onRender : function(ct, position){
		Ext.ux.QueryPage.superclass.onRender.call(this, ct, position);
		$('#'+this.body.id).query(this.fields);
	}
});	